/*******************************************************************************
 * Copyright (C) 2019 China Micro Semiconductor Limited Company. All Rights Reserved.
 *
 * This software is owned and published by:
 * CMS LLC, No 2609-10, Taurus Plaza, TaoyuanRoad, NanshanDistrict, Shenzhen, China.
 *
 * BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND
 * BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT.
 *
 * This software contains source code for use with CMS
 * components. This software is licensed by CMS to be adapted only
 * for use in systems utilizing CMS components. CMS shall not be
 * responsible for misuse or illegal use of this software for devices not
 * supported herein. CMS is providing this software "AS IS" and will
 * not be responsible for issues arising from incorrect user implementation
 * of the software.
 *
 * This software may be replicated in part or whole for the licensed use,
 * with the restriction that this Disclaimer and Copyright notice must be
 * included with each copy of this software, whether used in part or whole,
 * at all times.
 */

/****************************************************************************/
/** \file isr.c
**
**	History:
**
*****************************************************************************/
/****************************************************************************/
/*	include files
*****************************************************************************/
#include "polsys.h"

/****************************************************************************/
/*	Local pre-processor symbols/macros('#define')
*****************************************************************************/

/****************************************************************************/
/*	Global variable definitions(declared in header file with 'extern')
*****************************************************************************/

/****************************************************************************/
/*	Local type definitions('typedef')
*****************************************************************************/

/****************************************************************************/
/*	Local variable  definitions('static')
*****************************************************************************/

/****************************************************************************/
/*	Local function prototypes('static')
*****************************************************************************/

/****************************************************************************/
/*	Function implementation - global ('extern') and local('static')
*****************************************************************************/

/****************************************************************************
 ** \brief	NMI_Handler
 **
 ** \param [in]  none
 ** \return none
 ** \note
 ****************************************************************************/
void NMI_Handler(void)
{
}
/****************************************************************************
 ** \brief	HardFault_Handler
 **
 ** \param [in]  none
 ** \return none
 ** \note
 ****************************************************************************/
void HardFault_Handler(void)
{
    // Pow_Reset();
    SYS_ResetMCU();
}

/****************************************************************************
 ** \brief	SVC_Handler
 **
 ** \param [in]  none
 ** \return none
 ** \note
 ****************************************************************************/
void SVC_Handler(void)
{
}

/****************************************************************************
 ** \brief	PendSV_Handler
 **
 ** \param [in]  none
 ** \return none
 ** \note
 ****************************************************************************/
void PendSV_Handler(void)
{
}

extern void Board_AwakenIntEvent(void);
/****************************************************************************
 ** \brief	GPIO0_IRQHandler
 **
 ** \param [in]  none
 ** \return none
 ** \note
 ****************************************************************************/
void GPIO0_IRQHandler(void)
{
    GPIO0->ICLR = 0xFF;
    Board_AwakenIntEvent();
}

/****************************************************************************
 ** \brief	GPIO1_IRQHandler
 **
 ** \param [in]  none
 ** \return none
 ** \note
 ****************************************************************************/
void GPIO1_IRQHandler(void)
{
    GPIO1->ICLR = 0xFF;
    Board_AwakenIntEvent();
}
/****************************************************************************
 ** \brief	GPIO2_IRQHandler
 **
 ** \param [in]  none
 ** \return none
 ** \note
 ****************************************************************************/
void GPIO2_IRQHandler(void)
{
    GPIO2->ICLR = 0xFF;
    Board_AwakenIntEvent();
}
/****************************************************************************
 ** \brief	GPIO3_IRQHandler
 **
 ** \param [in]  none
 ** \return none
 ** \note
 ****************************************************************************/
void GPIO3_IRQHandler(void)
{
    GPIO3->ICLR = 0xFF;
    Board_AwakenIntEvent();
}
/****************************************************************************
 ** \brief	GPIO4_IRQHandler
 **
 ** \param [in]  none
 ** \return none
 ** \note
 ****************************************************************************/
void GPIO4_IRQHandler(void)
{
    GPIO4->ICLR = 0xFF;
    Board_AwakenIntEvent();
}

/****************************************************************************
 ** \brief	CCP_IRQHandler
 **
 ** \param [in]  none
 ** \return none
 ** \note
 ****************************************************************************/
void CCP_IRQHandler(void)
{
}

/****************************************************************************
 ** \brief	WWDT_IRQHandler
 **
 ** \param [in]  none
 ** \return none
 ** \note
 ****************************************************************************/
void WWDT_IRQHandler(void)
{
}

/****************************************************************************
 ** \brief	ACMP_IRQHandler
 **
 ** \param [in]  none
 ** \return none
 ** \note
 ****************************************************************************/
void ACMP_IRQHandler(void)
{
}
/****************************************************************************
 ** \brief	UART0_IRQHandler
 **
 ** \param [in]  none
 ** \return none
 ** \note
 ****************************************************************************/
void UART0_IRQHandler(void)
{
}

void SmcpLink_EvReceivedData(u8 byte);
/****************************************************************************
 ** \brief	UART1_IRQHandler
 **
 ** \param [in]  none
 ** \return none
 ** \note
 ****************************************************************************/
void UART1_IRQHandler(void)
{
    if(Uart1_GetRecivedFlag())
    {
        Uart1_ClearRecivedFlag();
        SmcpLink_EvReceivedData(Uart1_GetRecivedbyte());
        // Uart1_SendByte(Uart1_GetRecivedbyte());
    }
}
/****************************************************************************
 ** \brief	TMR0_IRQHandler
 **
 ** \param [in]  none
 ** \return none
 ** \note
 ****************************************************************************/
void TMR0_IRQHandler(void)
{
    Tim_ClrIrqFlag(TMR0);
    SPwm_EvTimer();
}
/****************************************************************************
 ** \brief	TMR1_IRQHandler
 **
 ** \param [in]  none
 ** \return none
 ** \note
 ****************************************************************************/
void TMR1_IRQHandler(void)
{
    Tim_ClrIrqFlag(TMR1);
}

/****************************************************************************
 ** \brief	TMR2_IRQHandler
 **
 ** \param [in]  none
 ** \return none
 ** \note
 ****************************************************************************/
void TMR2_IRQHandler(void)
{
    Tim_ClrIrqFlag(TMR2);
}
/****************************************************************************
 ** \brief	TMR3_IRQHandler
 **
 ** \param [in]  none
 ** \return none
 ** \note
 ****************************************************************************/
void TMR3_IRQHandler(void)
{
    Tim_ClrIrqFlag(TMR3);
}

/****************************************************************************
 ** \brief	I2C_IRQHandler
 **
 ** \param [in]  none
 ** \return none
 ** \note
 ****************************************************************************/
void I2C_IRQHandler(void)
{
}
/****************************************************************************
 ** \brief	SPI_IRQHandler
 **
 ** \param [in]  none
 ** \return none
 ** \note
 ****************************************************************************/
void SPI_IRQHandler(void)
{
}
/****************************************************************************
 ** \brief	GPIO0_IRQHandler
 **
 ** \param [in]  none
 ** \return none
 ** \note
 ****************************************************************************/
void LVD_IRQHandler(void)
{
}
